#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>

int main(int argc, char* argv[]){
	if(argc < 2){
		printf("usage ./a.out <filename>\n");
		return 1;
	}

	printf("%s\n", argv[1]);
	if(access(argv[1],R_OK) == -1){
		printf("access denied\n");
	}else{
		printf("access success\n");
	}

	if(open(argv[1],O_RDONLY) ==-1){
		printf("open fail\n");
	}else{
		printf("open success\n");
	}
}

// ./a.out a.out
// ./a.out /etc/profile
// 